<?php
  require_once('scripts/restrict_access.php');
  if ($identity->accessLevel>20){
	header('Location: AccessDenied.php');
	exit;
}
require_once('scripts/processEditItem.php');
require_once('scripts/calculate_path.php');

$sql = 'SELECT * FROM `items` WHERE `itemId`= ? ';
$result = $dbRead->fetchRow($sql,$_GET['itemId']);
$size_of_result = sizeof($result);
?> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--

Design by Free CSS Templates
http://www.freecsstemplates.org
Released for free under a Creative Commons Attribution 2.5 License

Title      : Complimentary
Version    : 1.0
Released   : 20080409
Description: A two-column, fixed-width and lightweight template ideal for 1024x768 resolutions. Suitable for blogs and small websites.

-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Edit Item</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="CSS/ComplementaryDefault.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<!-- start header -->
<div id="header">
<div id="logo">
    <h1><a href="#">Find-it</a>
</h1></div>
<div id="menu">
  <ul>
    <li class="active"><a href="DBList.php"> Catalogs</a></li>
    <li><a href="ManageLabels.php">Labels</a></li>
    <li><a href="Index.php?logout">Logout </a></li>
    </ul>
</div>
</div>
<!-- end header -->
<!-- start page -->
<div id="page">
  <!-- start content -->
  <div id="content">
    <div class="post">
      <p><br />
      </p>
      <div class="searchfield">
      <!--This is the search field -->
        <form method="get" action="SearchResults.php?">
    <fieldset>
      <input name="searchtext" type="text" id="s" value="" />
      <input name="dbId" type="hidden" value="<?php echo $_GET['dbId'];?>" />
      <input type="submit" id="x" value="Search" />
      </fieldset>
  </form>
</div><br/>
<h1 class="title"><?php echo $_GET['name'];?></h1>
      
<div class="entry">
        <p>
        <?php echo $path.'--><a href="DBMain.php?dbId='.$_GET['dbId'].(($_GET['id']!=0) ? '&amp;id='.$_GET['id'] : "").'&amp;name='.$_GET['parentName'].'">'.$_GET['parentName'].'</a>' 
		//echo $path
		?>
        </p>
        <!--Form for input fields -->
        <form id="form1" method="post" action="">
          <div class="leftFields">
            <span class="warning">
           <?php	if ($_POST && isset($errors['itemName'])){ echo $errors['itemName'];}?><br/>
           </span>
            <label for="itemName">Item Name</label><br />
            <input value="<?php if ($_POST && $errors){
			  echo htmlentities($_POST['itemName'],ENT_COMPAT, 'UTF-8');
		  }else{echo htmlentities($result['itemName']);}?>" name="itemName" type="text" id="itemName" size="67" maxlength="150" />
          </div>
       
          <div class="rightTopFields">
            <span class="warning">
              <?php	if ($_POST && isset($errors['position'])){ echo $errors['position'];}?><br/>
            </span>
            <label for="position">Position</label><br />
            <input value="<?php if ($_POST && $errors){
			  echo htmlentities($_POST['position'],ENT_COMPAT, 'UTF-8');
		  }else{echo htmlentities($result['position']);}?>" name="position" type="text" id="position" size="5" maxlength="150" />
            
            &nbsp;
            <label for="checkedOut">Checked-out</label>
            <input name="checkedOut" type="checkbox" value="1" <?php echo ($result['checkedOut']==1 ? 'checked="checked"' : '');?> />
            
            
             
          </div>
          <div class="bottomFields">
          
            <label for="keywords">Keywords</label><br />
            <input value="<?php if ($_POST && $errors){
			  echo htmlentities($_POST['keywords'],ENT_COMPAT, 'UTF-8');
		  }else{echo htmlentities($result['keywords']);}?>" name="keywords" type="text" id="keywords" size="96" maxlength="150" /> 
            
            <p>Description<br />
            <textarea name="description" cols="95" rows="4"><?php if ($_POST && $errors){
   echo htmlentities($_POST['description'],ENT_COMPAT, 'UTF-8');
    }else{echo htmlentities($result['description']);}?>
            </textarea>
            <br/>
            
            <input type="submit" name="submit" id="submit" value="Submit" />
            <input type="submit" name="cancel" id="cancel" value="Cancel" /> 
            <!--Hiden values to be pased via the POST -->
            <input name="dbId" type="hidden" id="hiddenField" value="<?php echo $_GET['dbId']; ?>"/>
            <input name="id" type="hidden" id="hiddenField2" value="<?php echo $_GET['id']; ?>"/>
            <input name="itemId" type="hidden" id="hiddenField2" value="<?php echo $_GET['itemId']; ?>"/>
            <input name="parentName" type="hidden" id="hiddenField2" value="<?php echo $_GET['parentName']; ?>"/>
            <a href="scripts/process_delete_item.php?itemId=<?php echo $result['itemId']; ?>&amp;itemName=<?php echo $result['itemName']; ?>&amp;dbId=<?php echo $_GET['dbId']; ?>&amp;parentId=<?php echo $result['containerId']; ?>&amp;parentName=<?php echo $_GET['parentName']; ?>">Delete Item</a> </p>
          </div>
          
         
        </form>
        <div class="LeftPanel">
 <!-- This is a placeholder for the implementation of showing attched labels
          <p>
          <h2>Associated Labels</h2><br />
          This is category 1<br />
            Category 2<br />
            This is category 3<br />
            Another Category<br />
            asdkja askj ass  kjsad
          </p>
          <a href="#">Add/Remove Label</a>
 -->         
        </div>
        <!-- The bottomSpace div is for reserving space at the bottom for the footer -->
        <div class="bottomSpace">
          <p><br /><br />
          </p>
        </div>
      </div>
    </div>
</div>
  <!-- end content -->
  
</div>
<!-- end page -->
<!-- start footer -->
<div id="footer">
  <p id="legal">(c) 2012 Find-It. Design by <a href="http://www.freecsstemplates.org/">Free CSS Templates</a>.<br />
	</p>
</div>
<!-- end footer -->
</body>
</html>
